#pragma once
#include "ServiceHandler.h"
#include "IReactor.h"
#include "IData.h"
#include "IInfo.h"
#include "Handler.h"

class PatientValueEventServer :
	public ServiceHandler<SOCKET>
{
public:	
	PatientValueEventServer(IReactor<SOCKET>* _reactor, IInfo*);
	~PatientValueEventServer(void);

	bool open(SOCK_Stream* st);
	void handle_event(Handler<SOCKET> handle, Event_Type et);
	bool open(Handler<SOCKET> _handler);

private:
		typedef enum REQUEST_RESPONSE{
			NO_VALUE = 0,
			NO_PATIENT,
			OK_PATIENT,
			INVALID_REQ,
			REQ_EXIT
}REQUEST_RESPONSE;

	void clientConnected();
	void requestRecieved();

	void exit();
	void sendPatient();
	void noPatient();
	void invalidRequest();
	bool verifyRequest(char*);

	REQUEST_RESPONSE response;

	IInfo *myServer;
	IData* patient;

	static const char unitSeparator = 0x1F;
};